using System;
using RFS.BizLogic.PaiShi.Impl;
using RFS.Domain.PaiShi.Zuhuo;

namespace RFS.Domain.PaiShi
{
    public static class EXManager
    {
        
        // public static IOrderItem OfJiaoYiDayBasedBatch (this Object o, object src)
        // {
        //     var x = src as dynamic;
        //     var d= new OrderItem()
        //     {
        //         JiaoYiHao = x.交易批次,
        //         GongHuoPiCi = x.供货批次,
        //         GongHuoDanHao = x.供货单号,
        //         LocalId = x.id,
        //       
        //         Quantity = x.数量,
        //         RawData= x
        //     };
        //
        //
        //     try
        //     {
        //         d.DataCreatedTime = x.日期;
        //     }
        //     catch (Exception e)
        //     {
        //         Console.WriteLine($"[{ x.日期}] is not date");
        //         
        //     }
        //     return d;
        //     
        // }
        
        // public static IOrderItem OfFaHuoDataItem (this Object o, object src)
        // {
        //     var x = src as dynamic;
        //     var d= new OrderItem()
        //     {
        //         LocalId = x.id,
        //         BizId = x.供货单,
        //         BizIdMapingName = "供货单",
        //         Quantity = x.扎数 * 20 ,
        //         RawData= x
        //     };
        //
        //
        //     try
        //     {
        //         d.BizTime = x.质检时间 ;
        //     }
        //     catch (Exception e)
        //     {
        //         Console.WriteLine($"[{ x.日期}] is not date");
        //         
        //     }
        //     return d;
        //     
        // }
        
                
        
        public static IOrderItem OfYanShou_GHDataItem (this Object o, object src)
        {
            
            var x = src as dynamic;
            var d= new OrderItem()
            {
                OrdType = BizFlowNodeEnum.YanShou, 
                LocalId = x.id,
                BizId = x.供货单号,
                BizIdMapingName="供货单号",
                Quantity = x.数量,
                Amount = 0,
                RawData= x,
                // Product = new Product(x.供货商,x.品种,$"{x.长度}"),
                Product = new Product($"{x.供货商}",$"{x.品种}",$"{x.长度}")


            };


            try
            {
                d.BizTime = x.日期;
            }
            catch (Exception e)
            {
                
            }
            return d;
            
        }
        
                
        public static IOrderItem OfFaHuo_LuRuDataItem (this Object o, object src)
        {
            
            var x = src as dynamic;
            var d= new OrderItem()
            {
                OrdType = BizFlowNodeEnum.FaHuo, 
                LocalId = x.id,
                BizId = x.供货单,
                BizIdMapingName = "供货单",
                Quantity = x.扎数 * 20 ,
                RawData= x,
                Product = new Product($"{x.供货商}",$"{x.品种名称}",$"{x.长度}")
            };


            try
            {
                d.BizTime = x.质检时间 ;
            }
            catch (Exception e)
            {
                Console.WriteLine($"[{ x.日期}] is not a date");
                
            }
            return d;
            
        }
        
             
        public static IOrderItem OfOrderItem (this ZuhuaRecord src )
        {
            
            var x = src as ZuhuaRecord;
            var d= new OrderItem()
            {
                OrdType = BizFlowNodeEnum.FaHuo, 
                LocalId =(long) x.Id,
                BizId = x.发货单码 ,
                BizIdMapingName = "发货单码",
                Quantity = x.枝数  ,
                RawData= x,
                Product = new Product($"{x.供货商码}",$"{x.拍市品种名 }",$"{x.长度}")
            };


            try
            {
                d.BizTime = x.ZHTime ;
            }
            catch (Exception e)
            {
                // Console.WriteLine($"[{ x.日期}] is not a date");
                
            }
            return d;
            
        }
        
         
        public static IProductPriceItem OfProductPriceItem (this Object o, object src)
        {
            
            var x = src as dynamic;
            var d= new ProductPriceItem()
            {
                DateTime = x.日期,
                Product = new Product($"{x.供货商}",$"{x.品种}",$"{x.长度}"),
                Supplier = x.供货商,
                Price =(decimal) x.价格,
                
            };

 
            return d;
            
        }
        
        
        
        
        
    }
}